home *** CD-ROM | disk | FTP | other *** search
- Program Surface (Output);
-
- {****************************************************************************}
- { }
- { Program: Surface.Pas }
- { Programmer: Keith Shafer }
- { San Diego, CA 92120 }
- { }
- { This program is a pascal adaptation of the public domain program titled }
- { Surface.bas. It shows the graphic ability of the IBM PC or compatible }
- { when used with turbo pascal. }
- { }
- {****************************************************************************}
-
- Const Rho = 100;
- D = 2000;
- Theta = 0.1;
- Phi = 1.3;
- Var
- W, X, Y, Z, S1, S2, C1, C2 : Real;
- XE, YE, ZE, SX, SY, OldX, OldY, DX, SL : Real;
- I, J, FL, F, XP, YP : Integer;
- YMin : Array[0..639] of Integer;
- YMax : Array[0..639] of Integer;
-
-
- Function Find_Z : Real;
-
- Begin
- Find_Z:=14 * EXP (-0.04 * W) * COS (0.15 * W);
- End;
-
-
- Procedure Initialize;
-
- Var I : Integer;
-
- Begin
- S1:=Sin(Theta);
- S2:=Sin(Phi);
- C1:=Cos(Theta);
- C2:=Cos(Phi);
- For I:=0 to 639
- do YMin[I]:=199;
- W:=0; X:=0; Y:=0; Z:=0;
- XE:=0; YE:=0; ZE:=0; SX:=0; SY:=0; OldX:=0; OldY:=0;
- FL:=0; F:=0; DX:=0; SL:=0; YP:=0; XP:=0;
- End;
-
- Procedure Get_Values_N_Plot;
-
- Label Skip, return;
-
- Begin
- XE:=-X * S1 + Y * C1;
- YE:=-X * C1 * C2 - Y * S1 * C2 + Z * S2;
- ZE:=-X * S2 * C1 - Y * S1 * S2 - Z * C2 + Rho;
- SX:=D * XE / ZE + 320;
- SY:=-5 * D * YE / ZE / 12 + 120;
- If (SX < 0) or (SX > 639) then goto return;
- If FL = 0 then
- begin
- FL:=1;
- F:=0;
- end
- else
- begin
- DX:=OLDX - SX;
- If DX = 0 then DX:=1;
- SL:=(OLDY - SY) / DX;
- YP:=Round(OLDY);
- For XP:= Round(OLDX)+1 to Round(SX)
- do begin
- YP:=YP + Round(SL);
- If YP <= YMin[XP] then
- begin
- YMin[XP]:=YP;
- If F = 0 then
- begin
- Plot(XP,YP,1);
- F:=1;
- end;
- Draw(XP,YP,Round(OldX),Round(OldY),1);
- If YP < YMax[XP] then goto Skip
- else
- begin
- YMax[XP]:=YP;
- If F = 0 then
- begin
- Plot(XP,YP,1);
- F:=1;
- end;
- Draw(XP,YP,Round(OldX),Round(OldY),1);
- end;
- goto Skip;
- end; { yp <= ymin[xp] }
- If YP >= YMax[XP] then
- begin
- YMax[XP]:=YP;
- If F = 0 then
- begin
- Plot(XP,YP,1);
- F:=1;
- end;
- Draw(XP,YP,Round(OldX),Round(OldY),1);
- goto Skip;
- end;
- F:=0;
- Skip: end;
- end;
- return: OldX:=SX;
- OldY:=SY;
- End;
-
- Begin { main }
- Initialize;
- HiRes;
- HiResColor(15);
- For I:=24 downto -24
- do begin
- X:=I * 0.5;
- FL:=0;
- For J:=-60 to 60
- do begin
- Y:=J * 0.2;
- W:=X * X + Y * Y;
- Z:=Find_Z;
- Get_Values_N_Plot;
- end;
- end;
- End.